package com.xxgc.cloud.springcloudgateway.route;

import org.springframework.cloud.gateway.route.RouteLocator;
import org.springframework.cloud.gateway.route.builder.RouteLocatorBuilder;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * @program: SpringCloudStudy
 * @description: 代码的网关配置
 * @author: Mr.abel(ShiJiaYi)
 * @create: 2022-11-29 14:42
 **/
@Configuration
public class GatewayConfig {
    @Bean
    public RouteLocator getRouteLocator(RouteLocatorBuilder builder){
        return builder.routes()
                //路由配置
                //系统模块通用消费者
                .route("NullService",predicateSpec -> predicateSpec
                        .path("/")//拦截路径
                        .filters(gatewayFilterSpec ->
                                gatewayFilterSpec
                                        .filter(new NullServiceFilter()))// 自定义局部过滤器
                        .uri("lb://spring-cloud-auth")//路由转发到某个服务
                )
                .build();
    }
}
